use std::os::raw::c_char;
use std::ffi::CString;
use std::ffi::CStr;

#[repr(C)]
pub struct word_info_t
{
    pub word: *const c_char,
    pub age: i32,
}

extern "C"
{
    pub fn get_word (w_info: *const word_info_t) -> *const c_char;
}


fn main() {
    println!("Hello, world!");
    // 生成C字符串。
    let cstr = CString::new("Cisco!").expect("CString::new() failed");
    let w_info = word_info_t
    {
        word: cstr.as_ptr(),
        age: 32_i32,
    };
    unsafe
    {
        let s = CStr::from_ptr(get_word(&w_info));
        println!("word: {:?}, ", s);
    };

}
